﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AL100.BankApplication.BLL
{
    /// <summary>
    /// Visitor class that will withdraw 10 € on each account 
    /// of the visited <see cref="Bank"/>.
    /// </summary>
    public class TenEurosVisitor : IVisitor
    {
        /// <summary>
        /// Visits the specified visitable.
        /// </summary>
        /// <param name="visitable">The visitable.</param>
        public void Visit(IVisitable visitable)
        {
            // Let's cast the visitable object back to 
            // its wanted type..
            Bank bank = visitable as Bank;

            // Withdraw 10 € from each account..
            foreach (var account in bank.Accounts)
            {
                account.Withdraw(10);
            }
        }
    }
}
